package com.example.mpandroidchart1107;

import androidx.appcompat.app.AppCompatActivity;

import android.graphics.Color;
import android.os.Bundle;

import com.github.mikephil.charting.charts.RadarChart;
import com.github.mikephil.charting.data.RadarData;
import com.github.mikephil.charting.data.RadarDataSet;
import com.github.mikephil.charting.data.RadarEntry;
import com.github.mikephil.charting.interfaces.datasets.IRadarDataSet;

import java.util.ArrayList;
import java.util.List;

public class Main4Activity extends AppCompatActivity {

    @Override

        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main4);
            RadarChart chart= findViewById(R.id.chart);
            /*3.*/

            List<IRadarDataSet> sets=new ArrayList<>();



            float[] f1={78f,67f,50f,67f,73f};
            RadarDataSet d1=getDataSet(f1,"好人");
            sets.add(d1);
            d1.setColor(Color.parseColor("#00FF7F"));
            d1.setDrawFilled(true);


            float[] f2={59f,35f,58f,80f,76f};
            RadarDataSet d2=getDataSet(f2,"肉");
            sets.add(d2);
            d2.setColor(Color.parseColor("#1E90FF"));
            d2.setDrawFilled(true);


            RadarData data=new RadarData(sets);
            chart.setData(data);
            chart.invalidate();

        }


        private RadarDataSet getDataSet(float [] data,String title){

            List<RadarEntry> list=new ArrayList<>();
            for (int i=0; i<data.length;i++){
                RadarEntry radarEntry=new RadarEntry(data[i]);
                list.add(radarEntry) ;
            }
            return new RadarDataSet(list,title);//
        }

    }
